﻿<script type="text/javascript">

    var HashParamList = {};
    HashParamList.DelUrl = "";
    HashParamList.EditUrl = "";
    HashParamList.DetailUrl = "";

    HashParamList.DeleteFormatter = function (value, rec, index) {
        if (rec.StateID == 1)
            return "";
        return "<a  class='btn-del' href='" + HashParamList.DelUrl + "/" + rec.UID + "' onclick='HashParamList.Delete(this); return false;' >删除</a>";
    }

    HashParamList.EditFormatter = function (value, rec, index) {
        return "<a  class='btn-edit' href='" + $("#editHashParamUrl").val() + "/" + rec.UID + "' onclick='HashParamList.Edit(this); return false;' >修改</a>";
    }

    HashParamList.DetailFormatter = function (value, rec, index) {
        if (rec.StateID < 1)
            return "";
        return "<a  class='btn-list' href='" + HashParamList.DetailUrl + "/" + rec.HashParameterTypeCodeID + "' onclick='HashParamList.Tree(this); return false;' >参数管理</a>";
    }
    HashParamList.StateFormatter = function (value, rec, index) {
        return value == "Enable" ? "启用" : "禁用";
    }

    HashParamList.Delete = function (e) {
        if (!confirm("确认要删除吗？"))
            return;
        $.post($(e).attr("href"), function (data) {
            if (data.IsOK) {
                $('#tbHashParamList').datagrid('reload');
            }
            else
                alert(data.Description);
        });
    }

    HashParamList.Edit = function (e) {
        $.createWin({ url: e.href, width: 600, height: 350, title: '修改哈希参数分类' });
        return false;
    }
    HashParamList.Tree = function (e) {
        var title = $(e).parents("tr").find("td:first").text() + "(" + $(e).parents("tr").find("[field='HashParameterTypeCodeID']").text() + ")";
        Common.ShowTab(e, title);
    }

    $(document).ready(function () {
        //参数初始化
        HashParamList.DelUrl = $("#delHashParamUrl").val();
        HashParamList.DetailUrl = $("#detailHashParamUrl").val();
        HashParamList.EditlUrl = $("#serviceEditHashParamUrl").val();

        //呈现列表数据
        $('#tbHashParamList').datagrid({ pagination: true });

        $("#btnHashParamSearch").unbind('click');
        $("#btnHashParamSearch").click(function () {
            $('#tbHashParamList').datagrid({ pageNumber: 1, queryParams: { HashParameterTypeCode: $("#HashParameterTypeCode").val(), HashParameterTypeCodeID: $("#HashParameterTypeCodeID").val()} });
        });
    });

</script>
@Html.Hidden("detailHashParamUrl", Url.Action("ParamList"))
@Html.Hidden("delHashParamUrl", Url.Action("Delete"))
@Html.Hidden("editHashParamUrl", Url.Action("Edit"))
<div class="tt-attach">
    <ul class="op"> 
        <li>
           类型代码： @Html.TextBox("HashParameterTypeCode", "", new
            {
                style = "width:100px;",
                @class = "search-input",
                title = "请输入类型代码进行搜索"
            })
            类型标识： @Html.TextBox("HashParameterTypeCodeID", "", new
            {
                style = "width:100px;",
                @class = "search-input",
                title = "请输入类型标识进行搜索"
            })
            <input id="btnHashParamSearch" class="search-button" value="搜索" type="button" />
        </li>
    </ul>
</div>
<div style="padding: 5px 10px;">
    <table id="tbHashParamList" style="height: auto" striped="true" rownumbers="true" nowrap="false" fitColumns="true" title="" iconcls="icon-edit"
    singleselect="true" idfield="UID" url="@Url.Action("ListData")">
        <thead>
            <tr>
                <th field="HashParameterTypeName" width="170">
                    类型名称
                </th>
                <th field="HashParameterTypeCode" formatter="HashParamList.PriorityFormatter" width="120">
                    类型代码
                </th>
                <th field="HashParameterTypeCodeID" width="60" align="center">
                    类型标识
                </th>
                <th field="Remark" width="200">
                    备注
                </th>
                <th field="StateCode" formatter="HashParamList.StateFormatter" width="50" align="center">
                    状态
                </th>
                <th field="参数管理" width="50" formatter="HashParamList.DetailFormatter" align="center">
                    参数管理
                </th>
                <th field="修改" width="50" formatter="HashParamList.EditFormatter" align="center">
                    修改
                </th>
                <th field="删除" width="50" formatter="HashParamList.DeleteFormatter" align="center">
                    删除
                </th>
            </tr>
        </thead>
    </table>
</div>
